package org.xtframe.util;

import org.apache.struts2.ServletActionContext;
import org.xtframe.bean.SystemConfig;
import org.xtframe.entity.ServerData;
import org.xtframe.entity.UserData;

public class ContextUtil {
	
	/**
	 * 获取服务器数据
	 * @return
	 */
	public static ServerData getServerData(){
		Object serverData = ServletActionContext.getServletContext().getAttribute(SystemConfig.SERVER_DATA);
		if(serverData == null) return null;
		else return (ServerData)serverData;
	}
	
	/**
	 * 获取当前用户数据
	 * @return
	 */
	public static UserData getCurrentUserData(){
		Object userData = ServletActionContext.getRequest().getSession().getAttribute(SystemConfig.LOGIN_USER);
		if(userData == null) return null;
		else return (UserData)userData;
	}
	
}
